
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.obscure.delib.*;


interface SplashSubState 
{
	public final int sub_splash_logo     =0;
	public final int sub_splash_logogame =1;
}

public class ScreenStateSplash implements ScreenState {

	private SpriteBatch m_spriteBatch;
    private deSprite m_splashDeSprite;
    private deSprite m_splashGameDeSprite;
    private long m_StartTime;
    private boolean m_isStateDone=false;
    private int m_subState = SplashSubState.sub_splash_logo;
    
	public int m_NextState=0;
	public ScreenStateSplash(Application app) {
		// TODO Auto-generated constructor stub

		m_spriteBatch = new SpriteBatch();
		m_splashDeSprite = new deSprite();
		m_splashDeSprite.setSptiteBatch(m_spriteBatch);
		m_splashDeSprite.loadData(DATA_SPRITE.SPR_SPLASH);
		
		m_splashGameDeSprite = new deSprite();
		m_splashGameDeSprite.setSptiteBatch(m_spriteBatch);
		m_splashGameDeSprite.loadData(DATA_SPRITE.SPR_LOGO);
		
		m_StartTime= System.currentTimeMillis();

	}

	@Override
	public void update(Application app) {
		if( System.currentTimeMillis()-m_StartTime > 500) {
			m_StartTime= System.currentTimeMillis();
			if(m_subState==SplashSubState.sub_splash_logogame) {
				m_NextState =GameState.STATE_GP;//.STATE_MM;
				m_isStateDone=true;
			}
			m_subState=SplashSubState.sub_splash_logogame;
		}
		
	}

	@Override
	public void render(Application app) {
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);   //clear screen
        Gdx.gl.glClearColor(255, 255, 255, 255);    //fill screen with white color
		
        if(m_subState==SplashSubState.sub_splash_logogame) {
			m_splashDeSprite.paintFrame(0, 0, 0);
        } else {
			m_splashGameDeSprite.paintFrame(0, 0, 0);
        }
	}

	@Override
	public boolean isDone() {
		return m_isStateDone;
	}

	@Override
	public void dispose() {
		m_spriteBatch.dispose();
		m_splashDeSprite.dispose();
		
	}
	
	public int getNextState() {
		return m_NextState;
	}

}
